## Events

In Helene, Events allow bidirectional real-time communication by broadcasting data from the server to one or more connected clients. Events are powerful mechanisms for updating clients with real-time information, such as changes in data, notifications, or any other type of event-triggered action.

To use Events in Helene, you need to define the Events on the server and subscribe to them on the client side.

Events allow you to invert the control of the application by casting a piece of data to a set of clients.

You can group these clients in different ways by using channels.

Events need to be declared first:

```js
server.addEvent('event', { protected: false })
```

Then you can subscribe to it from the client:

```js
client.subscribe('event')
```
Once the client is subscribed, it will start receiving data emitted by the server whenever the 'eventName' event is triggered.
You can now listen to that event in the client app:

```js
client.on('event', console.log)
```

We can emit something from the server:

```js
server.emit('event', 42)
```

When the clients receive this data, the corresponding event listener (registered with `client.on('event', callback)`) will be triggered, allowing the client to handle the received data.

Events are incredibly flexible and can be used to broadcast various types of real-time information, such as chat messages, live updates, notifications, or any other dynamic data.
Overall, Events in Helene facilitate real-time communication between the server and connected clients, enabling dynamic and interactive applications that respond to changes in real-time. They are an essential feature for building modern real-time applications and can significantly enhance the user experience by providing live updates and immediate feedback.